var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [{
			colkey : "job_number",
			name : "工号"
		},{
			colkey : "record_date",
			name : "日期"
		},{
			colkey : "conditions",
			name : "社保情况",
				renderData : function(rowindex,data, rowdata, column) {
					if(data==1){ return "增"}else{return "减"};
				}
		},{
			colkey : "pname",
			name : "姓名",
			
		},{
			colkey : "sex",
			name : "性别",
				renderData : function(rowindex,data, rowdata, column) {
					if(data==1){ return "男"}else{return "女"};
				}
		},{
			colkey : "dname",
			name : "部门",
			
		},{
			colkey : "position_name",
			name : "职务",
			
		},{
			colkey : "address",
			name : "身份证地址",
			
		},{
			colkey : "IdCard",
			name : "身份证号码",
			
		}, {
			colkey :"remake",
			name : "备注",
		}],
		jsonUrl : rootPath + '/hrsocial/social_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#addOrder").click("click", function() {
		addAccount();
	});
	$("#editOrder").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#delFuns").click("click", function() {
		delAccounts();
	});
	$("#addOrders").click("click", function() {
		addAccounts();
	});
	$("#delFunsocal").click("click", function() {
		deAccountsocal();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
			
		});
	});
	
});





function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "编辑社保信息 ",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/hrsocial/social_edit.shtml?id=' + cbox
	});
}
function deAccountsocal() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择一项！！");
		return;
	}
	layer.confirm('是否取消？', function(index) {
		var url = rootPath + '/hrsocial/social_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('取消成功');
			grid.loadData();
		} else {
			layer.msg('取消失败');
		}
	});
	
}
